package com.mycompany.app.user.dao;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;

import com.mycompany.app.model.Perfil;
import com.mycompany.app.model.User;

public class PerfilDAO implements IPerfilDAO{
	
	@Resource
    private SessionFactory sessionFactory;
 
    /**
     * Get Hibernate Session Factory
     *
     * @return SessionFactory - Hibernate Session Factory
     */
    public SessionFactory getSessionFactory() {
        return sessionFactory;
    }
 
    /**
     * Set Hibernate Session Factory
     *
     * @param SessionFactory - Hibernate Session Factory
     */
    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }

	public List<Perfil> getPerfilsByUser(User user) {
		List list = getSessionFactory().getCurrentSession()
                .createQuery("from Perfil where user=?")
                .setParameter(0, user).list();
		 return list;
	}

}
